/*
 * @Description:
 * @Author: maxyang
 * @Date: 2022-06-21 23:08:58
 * @LastEditTime: 2022-07-03 18:31:45
 * @LastEditors: liutq
 * @Reference:
 */
package aliyun

import (
	"fmt"
	"strconv"

	dysmsapi "github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
)

func SendMsg(phone int64, code_ string) error {
	client, err := dysmsapi.NewClientWithAccessKey("cn-qingdao", "LTAI5tB6fq7T5yKrQgQ6wTwG", "aTbyfMZNUAyLvYOSHr2xbvKobEssWM")

	if err != nil {
		return err
	}
	request := dysmsapi.CreateSendSmsRequest()
	request.Scheme = "https"
	code := "{\"code\": " + code_ + "}"
	request.PhoneNumbers = strconv.FormatInt(phone, 10) //接收短信的手机号码
	request.SignName = "鲸寻文化"                           //短信签名名称
	request.TemplateCode = "SMS_243551714"              //短信模板ID
	request.TemplateParam = code

	_, err = client.SendSms(request)
	if err != nil {
		fmt.Print(err.Error())
		return err
	}
	return nil
}
